#include<iostream>
using namespace std;
int main() {
    int n, m, y, x[100];
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> x[i];
    for (int i = 0; i < m; i++) {
        y = x[n - 1];
        for (int j = n - 1; j > 0; j--)
            x[j] = x[j - 1];
        x[0] = y;
    }
    for (int i = 0; i < n; i++) {
        if (i < n - 1)
            cout << x[i] << " ";
        else
            cout << x[i];
    }
}